//index.js
import Vue from "vue"
import Router from "vue-router"
//添加以下代码

Vue.use(Router)
// 先把vueRouter原型对象的push、replace保存一份
let originPush = Router.prototype.push
let originReplace = Router.prototype.replace
// 重写push和replace
// 第一个参数，告诉原来push方法，往哪里跳转，传递哪些参数
// 第二个参数是成功的回调
// 第三个参数是失败的回调
Router.prototype.push = function(location,resolve,reject){
  if(resolve && reject){
    // call和apply区别
    // 相同点：都可以调用函数一次，都可以篡改函数的上下文一次
    // 不同点：call和apply传递参数：call传递参数用逗号隔开，apply方法传递数组
    originPush.call(this,location,resolve,reject)
  }else{
    originPush.call(this,location,() => {}, () => {})
  }
}
Router.prototype.replace = function(location,resolve,reject){
  if(resolve && reject){
    originReplace.call(this,location,resolve,reject)
  }else{
    originReplace.call(this,location,() => {}, () => {})
  }
}

export default new Router({
    mode:"hash",
    base:process.env.BASE_URL,
    routes:[
        {
        path:'/',
        name:'login',
        component :()=> import('@/views/login.vue'),
        meta:{
            title:'登录页'
        }
    },
    {
        path: '/setpas',
        name: 'setpas',
        component: () => import('../views/setpas.vue')
      },
      {
        path: '/res',
        name: 'res',
        component: () => import('../views/result.vue')
      },
      {
        path: '/repas1',
        name: 'repas1',
        component: () => import('../views/repas1.vue')
      },
      {
        path: '/repas2',
        name: 'repas2',
        component: () => import('../views/repas2.vue')
      },
     


]
})